/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ClientGUI;
import java.awt.*;
import Client.ClientController;


/**
 *
 * @author cypek
 */
public class ButtonOnCanvas extends Canvas implements Runnable {


    private ClientController clientController;
    private Thread t;
    private ClientGUIGFX gfx;

    public ButtonOnCanvas(ClientController clientController) {
        gfx = new ClientGUIGFX();
        this.clientController = clientController;


        t = new Thread(this);
        t.start();
    }



    private Image loadImage (String pad){
        return Toolkit.getDefaultToolkit().getImage(getClass().getResource(pad));
    }
    // This is overriding the paint event of Canvas, graphics is the graphics context of the canvas
    @Override
    public void paint(Graphics g) {

        for(int i = 0; i< gfx.getImageList().size(); i++)
        {
            //
            g.drawImage(gfx.getImageList().get(i) ,  i*20, 0, 20, 20, this);
            if(clientController.getClient().getCurrentFloor() == i)
            {
                g.drawImage(gfx.getImageListA().get(i) , i*20, 0, 20, 20, this);
            }
        }
        
    }

    @Override
    public void run()
    {
        while(true){
            try{
                this.repaint();
                Thread.sleep(900);
            }
            catch(Exception ex )
            {

            }
            
        }
    }
}
